home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / ws_tetri.swf / scripts / %3Cdefault package%3E / wsbutton.as < prev    next >
Encoding:
Text File  |  2007-03-21  |  3.5 KB  |  136 lines

  1. function WSbutton()
  2. {
  3.    this.init();
  4. }
  5. WSbutton.prototype = new MovieClip();
  6. Object.registerClass("wsbutton",WSbutton);
  7. b = WSbutton.prototype;
  8. b.init = function()
  9. {
  10.    var _loc1_ = this;
  11.    if(_loc1_.aktiv)
  12.    {
  13.       _loc1_.gotoAndStop(_loc1_.labelTxt + "_over");
  14.       _loc1_.enabled = false;
  15.    }
  16.    else
  17.    {
  18.       _loc1_.gotoAndStop(_loc1_.labelTxt);
  19.    }
  20.    _loc1_.ursprungX = _loc1_._x;
  21.    _loc1_.ursprungY = _loc1_._y;
  22.    _loc1_.abstandX = _loc1_._width / 2;
  23.    _loc1_.abstandY = _loc1_._height / 2;
  24.    _loc1_.minX = _loc1_.ursprungX - _loc1_.abstandX;
  25.    _loc1_.maxX = _loc1_.ursprungX + _loc1_.abstandX;
  26.    _loc1_.minY = _loc1_.ursprungY - _loc1_.abstandY;
  27.    _loc1_.maxY = _loc1_.ursprungY + _loc1_.abstandY;
  28.    _loc1_.imBereich = 0;
  29.    _loc1_.magnetOut = 3;
  30.    _loc1_.tiefe = _loc1_.getDepth();
  31. };
  32. b.onRollOver = function()
  33. {
  34.    var _loc1_ = this;
  35.    _loc1_.gotoAndStop(_loc1_.labelTxt + "_over");
  36.    if(!_loc1_.single)
  37.    {
  38.       _loc1_.swapDepths(100);
  39.    }
  40. };
  41. b.onRollOut = function()
  42. {
  43.    var _loc1_ = this;
  44.    _loc1_.gotoAndStop(_loc1_.labelTxt);
  45.    if(!_loc1_.single)
  46.    {
  47.       _loc1_.swapDepths(_loc1_.tiefe);
  48.    }
  49. };
  50. b.onPressEvent = function()
  51. {
  52.    var _loc1_ = this;
  53.    delete _loc1_.onEnterFrame;
  54.    if(!_loc1_.single)
  55.    {
  56.       var _loc3_ = _root.aktiverBereich;
  57.       var _loc2_ = "b_" + _loc3_;
  58.       _loc1_._parent[_loc2_].gotoAndStop(_loc3_);
  59.       _loc1_._parent[_loc2_].aktiv = false;
  60.       _loc1_._parent[_loc2_].enabled = true;
  61.       _root.aktiverBereich = _loc1_.labelTxt;
  62.       _loc1_.aktiv = true;
  63.    }
  64.    _loc1_.gotoAndStop(_loc1_.labelTxt + "_over");
  65.    _loc1_.enabled = false;
  66.    _loc1_.swapDepths(_loc1_.tiefe);
  67.    _loc1_.moveOut();
  68. };
  69. b.onMouseMove = function()
  70. {
  71.    if(!this.aktiv)
  72.    {
  73.       this.checkBorder();
  74.    }
  75. };
  76. b.checkBorder = function()
  77. {
  78.    var _loc1_ = this;
  79.    var _loc2_ = _root;
  80.    if(_loc2_._xmouse > _loc1_.minX && _loc2_._xmouse < _loc1_.maxX && _loc2_._ymouse > _loc1_.minY && _loc2_._ymouse < _loc1_.maxY)
  81.    {
  82.       _loc1_.moveIn();
  83.    }
  84.    else
  85.    {
  86.       _loc1_.moveOut();
  87.    }
  88. };
  89. b.moveIn = function()
  90. {
  91.    var _loc1_ = this;
  92.    _loc1_.imBereich = 1;
  93.    _loc1_.onEnterFrame = function()
  94.    {
  95.       var _loc1_ = this;
  96.       _loc1_.neuX = _root._xmouse;
  97.       _loc1_.neuY = _root._ymouse;
  98.       _loc1_.wegX = _loc1_.neuX - _loc1_._x;
  99.       _loc1_.wegY = _loc1_.neuY - _loc1_._y;
  100.       _loc1_._x += Math.round(_loc1_.wegX / _loc1_.magnet);
  101.       _loc1_._y += Math.round(_loc1_.wegY / _loc1_.magnet);
  102.       if(_loc1_.wegX == _loc1_.wegX_alt && _loc1_.wegY == _loc1_.wegY_alt)
  103.       {
  104.          delete _loc1_.onEnterFrame;
  105.       }
  106.       _loc1_.wegX_alt = _loc1_.wegX;
  107.       _loc1_.wegY_alt = _loc1_.wegY;
  108.    };
  109. };
  110. b.moveOut = function()
  111. {
  112.    var _loc1_ = this;
  113.    if(_loc1_.imBereich == 1)
  114.    {
  115.       _loc1_.imBereich = 0;
  116.       _loc1_.onEnterFrame = function()
  117.       {
  118.          var _loc1_ = this;
  119.          _loc1_.neuX = _loc1_.ursprungX;
  120.          _loc1_.neuY = _loc1_.ursprungY;
  121.          _loc1_.wegX = _loc1_.neuX - _loc1_._x;
  122.          _loc1_.wegY = _loc1_.neuY - _loc1_._y;
  123.          _loc1_._x += Math.round(_loc1_.wegX / _loc1_.magnetOut);
  124.          _loc1_._y += Math.round(_loc1_.wegY / _loc1_.magnetOut);
  125.          if(_loc1_.wegX == _loc1_.wegX_alt && _loc1_.wegY == _loc1_.wegY_alt)
  126.          {
  127.             _loc1_._x = _loc1_.ursprungX;
  128.             _loc1_._y = _loc1_.ursprungY;
  129.             delete _loc1_.onEnterFrame;
  130.          }
  131.          _loc1_.wegX_alt = _loc1_.wegX;
  132.          _loc1_.wegY_alt = _loc1_.wegY;
  133.       };
  134.    }
  135. };
  136.